854B - Maxim Buys an Apartment - CodeForces Solution


constructive algorithms math *1200

Please click on ads to support us..

C++ Code:

//#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
const int N=1e6+5,mod=1e9+7;
typedef long long ll;
typedef pair<int,int> PII;
void solve()
{
    int n,k;
    scanf("%d%d",&n,&k);
    int mi,mx;
    if(k==0) mi=0,mx=0;
    else
    {
        if(n==k)
        {
            printf("0 0\n");
            return;
        }
        mi=1;
        int a=n-k,b=k;
        mx=min(b,a/2)*2+a%2;
        mx=min(mx,b*2);
    }
    printf("%d %d\n",mi,mx);
}
int main()
{
    int t=1;
    //scanf("%d",&t);
    while(t--) solve();
    return 0;
}


Comments

Submit
0 Comments
More Questions

838A - Binary Blocks
1515D - Phoenix and Socks
1624D - Palindromes Coloring
1552F - Telepanting
1692G - 2Sort
1191A - Tokitsukaze and Enhancement
903A - Hungry Student Problem
52B - Right Triangles
1712A - Wonderful Permutation
1712D - Empty Graph
1712B - Woeful Permutation
1712C - Sort Zero
1028B - Unnatural Conditions
735B - Urbanization
746C - Tram
1278B - A and B
1353D - Constructing the Array
1269C - Long Beautiful Integer
1076A - Minimizing the String
913C - Party Lemonade
1313A - Fast Food Restaurant
681A - A Good Contest
1585F - Non-equal Neighbours
747A - Display Size
285A - Slightly Decreasing Permutations
515C - Drazil and Factorial
1151E - Number of Components
1151F - Sonya and Informatics
556A - Case of the Zeros and Ones
867A - Between the Offices